package com.task.manager.mapper;

import com.task.manager.domain.Project;
import org.apache.ibatis.jdbc.SQL;

public class ProjectSqlProvider {

    public String insertSelective(Project record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("t_project");
        
        if (record.getId() != null) {
            sql.VALUES("ID", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getProjectName() != null) {
            sql.VALUES("PROJECT_NAME", "#{projectName,jdbcType=VARCHAR}");
        }
        
        if (record.getProjectCode() != null) {
            sql.VALUES("PROJECT_CODE", "#{projectCode,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("CREATE_TIME", "#{createTime,jdbcType=VARCHAR}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("UPDATE_TIME", "#{updateTime,jdbcType=VARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Project record) {
        SQL sql = new SQL();
        sql.UPDATE("t_project");
        
        if (record.getProjectName() != null) {
            sql.SET("PROJECT_NAME = #{projectName,jdbcType=VARCHAR}");
        }
        
        if (record.getProjectCode() != null) {
            sql.SET("PROJECT_CODE = #{projectCode,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("CREATE_TIME = #{createTime,jdbcType=VARCHAR}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("UPDATE_TIME = #{updateTime,jdbcType=VARCHAR}");
        }
        
        sql.WHERE("ID = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}